Component({
  properties: {

  },
  data: {
    tabList:[
      {
        "pagePath": "pages/index/index",
        "text": "首页",
      },
      {
        "pagePath": "pages/other/classify",
        "text": "发现"
      },
      {
        "pagePath": "pages/blank/blank",
        "text": "空白"
      },
      {
        "pagePath": "pages/mine/mine",
        "text": "我的"
      }
    ],
    selected:0
  },
  methods: {
    switchTab(e){
      let key = Number(e.currentTarget.dataset.index);
      let tabList = this.data.tabList;
      let curSelected = this.data.selected;
      console.log('key=%s curSelected=%s',key,curSelected);
      if(curSelected !== key){
        this.setData({
          selected:key
        });
        wx.switchTab({
          url: `/${tabList[key].pagePath}`,
        })
      }
    }
  }
})

